package com.dabaozhan.modules.wx_app.service.impl;

import com.dabaozhan.common.utils.Utils;
import com.dabaozhan.modules.wx_app.dao.PurchaseFormMapper;
import com.dabaozhan.modules.wx_app.entity.FormQueryEntity;
import com.dabaozhan.modules.wx_app.entity.PurchaseFormEntity;
import com.dabaozhan.modules.wx_app.service.PurchaseFormService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author houzhong
 * @date 2019-01-25 10:07
 */

@Service("purchaseFormService")
public class PurchaseFormServiceImpl implements PurchaseFormService {

    @Autowired
    private PurchaseFormMapper purchaseFormMapper;

    @Override
    public int savePurchaseForm(PurchaseFormEntity v) {
        if (v.getId() == null) {
            v.setId(Utils.id().toString());
        }
        return purchaseFormMapper.save(v);
    }

    @Override
    public int updatePurchaseForm(PurchaseFormEntity v) {
        return purchaseFormMapper.update(v);
    }

    @Override
    public PurchaseFormEntity getPurchaseFormId(String orderNumber) {
        return purchaseFormMapper.getObjectById(orderNumber);
    }

    @Override
	public List<PurchaseFormEntity> getPurchaseList(FormQueryEntity entity) {
		return purchaseFormMapper.getPurchaseList(entity);
	}
}
